package day14;

public class hw5Duration {

    private int hours;
    private int minutes;
    private int seconds;

    // 三参构造器
    public hw5Duration(int hours, int minutes, int seconds) {
        this.hours = hours;
        this.minutes = minutes;
        this.seconds = seconds;
    }

    // 一参构造器，将总秒数转换为时分秒
    public hw5Duration(int totalSeconds) {
        this.hours = totalSeconds / 3600;
        this.minutes = (totalSeconds % 3600) / 60;
        this.seconds = totalSeconds % 60;
    }

    // get方法
    public int getHours() {
        return hours;
    }

    public int getMinutes() {
        return minutes;
    }

    public int getSeconds() {
        return seconds;
    }

    //set方法
    public void setHours(int hours) {
        this.hours = hours;
    }

    public void setMinutes(int Minutes) {
        this.minutes = Minutes;
    }

    public void setSeconds(int seconds) {
        this.seconds = seconds;
    }
    // 获取总秒数
    public int getTotalSeconds() {
        return hours * 3600 + minutes * 60 + seconds;
    }

    public String toString() {
        return hours + ":" + minutes + ":" + seconds;
    }
   
}
